home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / dist-packages / computerjanitor / cruft.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-10-12  |  5.1 KB  |  126 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import computerjanitor
  5.  
  6. class Cruft(object):
  7.     '''One piece of cruft to be cleaned out.
  8.  
  9.     A piece of cruft can be a file, a package, a configuration tweak
  10.     that is missing, or something else.
  11.     
  12.     This is a base class, which does nothing. Subclasses do the
  13.     actual work.
  14.     
  15.     '''
  16.     
  17.     def get_prefix(self):
  18.         """Return the unique prefix used to group this type of cruft.
  19.         
  20.         For example, the .deb package called 'foo' would have a prefix
  21.         of 'deb'. This way, the package foo is not confused with the
  22.         file foo, or the username foo.
  23.         
  24.         Subclasses SHOULD define this. The default implementation
  25.         returns the name of the class, which is rarely useful to
  26.         the user.
  27.         
  28.         """
  29.         return self.__class__.__name__
  30.  
  31.     
  32.     def get_prefix_description(self):
  33.         '''Return human-readable description of class of cruft.'''
  34.         return self.get_description()
  35.  
  36.     
  37.     def get_shortname(self):
  38.         '''Return the name of this piece of cruft.
  39.         
  40.         The name should be something that the user will understand.
  41.         For example, it might be the name of a package, or the full
  42.         path to a file.
  43.         
  44.         The name should be unique within the unique prefix returned
  45.         by get_prefix. The prefix MUST NOT be included by this method,
  46.         the get_name() method does that instead. The intent is that
  47.         get_shortname() will be used by the user interface in contexts
  48.         where the prefix is shown separately from the short name,
  49.         and get_name() when a single string is used.
  50.         
  51.         Subclasses MUST define this. The default implementation
  52.         raises an exception.
  53.         
  54.         '''
  55.         raise computerjanitor.UnimplementedMethod(self.get_shortname)
  56.  
  57.     
  58.     def get_name(self):
  59.         '''Return prefix plus name.
  60.         
  61.         See get_prefix() and get_shortname() for a discussion of
  62.         the prefix and the short name. This method will return
  63.         the prefix, a colon, and the short name.
  64.  
  65.         The long name will used to store state/configuration data:
  66.         _this_ package should not be removed.
  67.         
  68.         '''
  69.         return '%s:%s' % (self.get_prefix(), self.get_shortname())
  70.  
  71.     
  72.     def get_description(self):
  73.         '''Return a description of this piece of cruft.
  74.         
  75.         This may be arbitrarily long. The user interface will take
  76.         care of breaking it into lines or otherwise presenting it to
  77.         the user in a nice manner. The description should be plain
  78.         text, in UTF-8.
  79.         
  80.         The default implementation returns the empty string. Subclasses
  81.         MAY override this as they wish.
  82.         
  83.         '''
  84.         return ''
  85.  
  86.     
  87.     def get_disk_usage(self):
  88.         '''Return amount of disk space reserved by this piece of cruft.
  89.         
  90.         The unit is bytes.
  91.         
  92.         The disk space in question should be the amount that will be
  93.         freed if the cruft is cleaned up. The amount may be an estimate
  94.         (read: guess). It is intended to be shown to the user to help
  95.         them decide what to remove and what to keep.
  96.         
  97.         This will also be used by the user interface to better
  98.         estimate how much remaining time there is when cleaning
  99.         up a lot of cruft.
  100.         
  101.         For some types of cruft, this is not applicable and they should
  102.         return None. The base class implementation does that, so
  103.         subclasses MUST define this method if it is useful for them to
  104.         return something else.
  105.         
  106.         The user interface will distinguish between None (not
  107.         applicable) and 0 (no disk space being used).
  108.         
  109.         '''
  110.         pass
  111.  
  112.     
  113.     def cleanup(self):
  114.         '''Clean up this piece of cruft.
  115.         
  116.         Depending on the type of cruft, this may mean removing files,
  117.         packages, modifying configuration files, or something else.
  118.         
  119.         The default implementation raises an exception. Subclasses
  120.         MUST override this.
  121.         
  122.         '''
  123.         raise computerjanitor.UnimplementedMethod(self.cleanup)
  124.  
  125.  
  126.